-
Notifications
You must be signed in to change notification settings - Fork 324
Add Custom Exception Handler to Unwrap CompletionException for GraphQL Instrumentations
#10389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 57 metrics, 8 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.089 s) : 0, 1088759
Total [baseline] (10.794 s) : 0, 10794039
Agent [candidate] (1.09 s) : 0, 1090038
Total [candidate] (10.837 s) : 0, 10837303
section appsec
Agent [baseline] (1.278 s) : 0, 1278317
Total [baseline] (11.06 s) : 0, 11059588
Agent [candidate] (1.272 s) : 0, 1271610
Total [candidate] (10.962 s) : 0, 10962021
section iast
Agent [baseline] (1.232 s) : 0, 1232044
Total [baseline] (11.102 s) : 0, 11101600
Agent [candidate] (1.233 s) : 0, 1232870
Total [candidate] (11.234 s) : 0, 11233882
section profiling
Agent [baseline] (1.218 s) : 0, 1218451
Total [baseline] (10.977 s) : 0, 10977429
Agent [candidate] (1.21 s) : 0, 1210198
Total [candidate] (10.892 s) : 0, 10892250
gantt
title petclinic - break down per module: candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.175 ms) : 0, 1175
crashtracking [candidate] (1.185 ms) : 0, 1185
BytebuddyAgent [baseline] (651.358 ms) : 0, 651358
BytebuddyAgent [candidate] (652.121 ms) : 0, 652121
GlobalTracer [baseline] (286.092 ms) : 0, 286092
GlobalTracer [candidate] (286.551 ms) : 0, 286551
AppSec [baseline] (32.928 ms) : 0, 32928
AppSec [candidate] (32.99 ms) : 0, 32990
Debugger [baseline] (66.808 ms) : 0, 66808
Debugger [candidate] (67.567 ms) : 0, 67567
Remote Config [baseline] (593.713 µs) : 0, 594
Remote Config [candidate] (607.85 µs) : 0, 608
Telemetry [baseline] (9.664 ms) : 0, 9664
Telemetry [candidate] (8.889 ms) : 0, 8889
Flare Poller [baseline] (4.489 ms) : 0, 4489
Flare Poller [candidate] (4.491 ms) : 0, 4491
section appsec
crashtracking [baseline] (1.175 ms) : 0, 1175
crashtracking [candidate] (1.174 ms) : 0, 1174
BytebuddyAgent [baseline] (695.383 ms) : 0, 695383
BytebuddyAgent [candidate] (692.311 ms) : 0, 692311
GlobalTracer [baseline] (265.461 ms) : 0, 265461
GlobalTracer [candidate] (262.515 ms) : 0, 262515
AppSec [baseline] (175.348 ms) : 0, 175348
AppSec [candidate] (174.074 ms) : 0, 174074
Debugger [baseline] (66.506 ms) : 0, 66506
Debugger [candidate] (67.493 ms) : 0, 67493
Remote Config [baseline] (709.157 µs) : 0, 709
Remote Config [candidate] (701.202 µs) : 0, 701
Telemetry [baseline] (9.348 ms) : 0, 9348
Telemetry [candidate] (9.316 ms) : 0, 9316
Flare Poller [baseline] (3.651 ms) : 0, 3651
Flare Poller [candidate] (3.588 ms) : 0, 3588
IAST [baseline] (25.139 ms) : 0, 25139
IAST [candidate] (24.878 ms) : 0, 24878
section iast
crashtracking [baseline] (1.179 ms) : 0, 1179
crashtracking [candidate] (1.181 ms) : 0, 1181
BytebuddyAgent [baseline] (794.856 ms) : 0, 794856
BytebuddyAgent [candidate] (794.32 ms) : 0, 794320
GlobalTracer [baseline] (260.235 ms) : 0, 260235
GlobalTracer [candidate] (261.025 ms) : 0, 261025
AppSec [baseline] (33.709 ms) : 0, 33709
AppSec [candidate] (33.784 ms) : 0, 33784
Debugger [baseline] (66.83 ms) : 0, 66830
Debugger [candidate] (66.814 ms) : 0, 66814
Remote Config [baseline] (539.527 µs) : 0, 540
Remote Config [candidate] (550.975 µs) : 0, 551
Telemetry [baseline] (8.434 ms) : 0, 8434
Telemetry [candidate] (8.767 ms) : 0, 8767
Flare Poller [baseline] (3.471 ms) : 0, 3471
Flare Poller [candidate] (3.595 ms) : 0, 3595
IAST [baseline] (27.292 ms) : 0, 27292
IAST [candidate] (27.364 ms) : 0, 27364
section profiling
crashtracking [baseline] (1.215 ms) : 0, 1215
crashtracking [candidate] (1.199 ms) : 0, 1199
BytebuddyAgent [baseline] (707.468 ms) : 0, 707468
BytebuddyAgent [candidate] (702.88 ms) : 0, 702880
GlobalTracer [baseline] (227.61 ms) : 0, 227610
GlobalTracer [candidate] (225.619 ms) : 0, 225619
AppSec [baseline] (32.943 ms) : 0, 32943
AppSec [candidate] (32.503 ms) : 0, 32503
Debugger [baseline] (68.249 ms) : 0, 68249
Debugger [candidate] (68.078 ms) : 0, 68078
Remote Config [baseline] (621.075 µs) : 0, 621
Remote Config [candidate] (608.007 µs) : 0, 608
Telemetry [baseline] (8.885 ms) : 0, 8885
Telemetry [candidate] (8.828 ms) : 0, 8828
Flare Poller [baseline] (3.654 ms) : 0, 3654
Flare Poller [candidate] (3.617 ms) : 0, 3617
ProfilingAgent [baseline] (97.492 ms) : 0, 97492
ProfilingAgent [candidate] (96.978 ms) : 0, 96978
Profiling [baseline] (98.071 ms) : 0, 98071
Profiling [candidate] (97.558 ms) : 0, 97558
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.089 s) : 0, 1088709
Total [baseline] (8.768 s) : 0, 8767626
Agent [candidate] (1.09 s) : 0, 1089689
Total [candidate] (8.781 s) : 0, 8781196
section iast
Agent [baseline] (1.25 s) : 0, 1249559
Total [baseline] (9.398 s) : 0, 9398171
Agent [candidate] (1.241 s) : 0, 1240906
Total [candidate] (9.45 s) : 0, 9450175
gantt
title insecure-bank - break down per module: candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.175 ms) : 0, 1175
crashtracking [candidate] (1.176 ms) : 0, 1176
BytebuddyAgent [baseline] (652.278 ms) : 0, 652278
BytebuddyAgent [candidate] (652.812 ms) : 0, 652812
GlobalTracer [baseline] (286.314 ms) : 0, 286314
GlobalTracer [candidate] (286.755 ms) : 0, 286755
AppSec [baseline] (32.885 ms) : 0, 32885
AppSec [candidate] (32.859 ms) : 0, 32859
Debugger [baseline] (67.25 ms) : 0, 67250
Debugger [candidate] (67.113 ms) : 0, 67113
Remote Config [baseline] (603.259 µs) : 0, 603
Remote Config [candidate] (601.324 µs) : 0, 601
Telemetry [baseline] (8.872 ms) : 0, 8872
Telemetry [candidate] (8.997 ms) : 0, 8997
Flare Poller [baseline] (3.738 ms) : 0, 3738
Flare Poller [candidate] (3.754 ms) : 0, 3754
section iast
crashtracking [baseline] (1.202 ms) : 0, 1202
crashtracking [candidate] (1.184 ms) : 0, 1184
BytebuddyAgent [baseline] (808.476 ms) : 0, 808476
BytebuddyAgent [candidate] (801.911 ms) : 0, 801911
GlobalTracer [baseline] (263.629 ms) : 0, 263629
GlobalTracer [candidate] (261.729 ms) : 0, 261729
AppSec [baseline] (33.457 ms) : 0, 33457
AppSec [candidate] (34.81 ms) : 0, 34810
Debugger [baseline] (66.968 ms) : 0, 66968
Debugger [candidate] (65.601 ms) : 0, 65601
Remote Config [baseline] (545.229 µs) : 0, 545
Remote Config [candidate] (547.062 µs) : 0, 547
Telemetry [baseline] (8.422 ms) : 0, 8422
Telemetry [candidate] (8.647 ms) : 0, 8647
Flare Poller [baseline] (3.47 ms) : 0, 3470
Flare Poller [candidate] (3.556 ms) : 0, 3556
IAST [baseline] (27.579 ms) : 0, 27579
IAST [candidate] (27.374 ms) : 0, 27374
LoadParameters
See matching parameters
SummaryFound 1 performance improvements and 2 performance regressions! Performance is the same for 16 metrics, 17 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section baseline
no_agent (18.225 ms) : 18040, 18409
. : milestone, 18225,
appsec (18.558 ms) : 18372, 18743
. : milestone, 18558,
code_origins (18.618 ms) : 18433, 18802
. : milestone, 18618,
iast (17.94 ms) : 17760, 18121
. : milestone, 17940,
profiling (18.632 ms) : 18441, 18823
. : milestone, 18632,
tracing (18.305 ms) : 18123, 18487
. : milestone, 18305,
section candidate
no_agent (19.416 ms) : 19216, 19616
. : milestone, 19416,
appsec (18.799 ms) : 18607, 18991
. : milestone, 18799,
code_origins (18.515 ms) : 18327, 18703
. : milestone, 18515,
iast (17.831 ms) : 17652, 18010
. : milestone, 17831,
profiling (19.436 ms) : 19240, 19632
. : milestone, 19436,
tracing (17.802 ms) : 17625, 17980
. : milestone, 17802,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section baseline
no_agent (1.177 ms) : 1165, 1189
. : milestone, 1177,
iast (3.262 ms) : 3213, 3312
. : milestone, 3262,
iast_FULL (5.607 ms) : 5552, 5662
. : milestone, 5607,
iast_GLOBAL (3.653 ms) : 3599, 3706
. : milestone, 3653,
profiling (2.09 ms) : 2071, 2109
. : milestone, 2090,
tracing (1.769 ms) : 1755, 1784
. : milestone, 1769,
section candidate
no_agent (1.202 ms) : 1190, 1214
. : milestone, 1202,
iast (3.248 ms) : 3202, 3293
. : milestone, 3248,
iast_FULL (5.76 ms) : 5703, 5818
. : milestone, 5760,
iast_GLOBAL (3.609 ms) : 3559, 3659
. : milestone, 3609,
profiling (1.962 ms) : 1945, 1979
. : milestone, 1962,
tracing (1.805 ms) : 1790, 1821
. : milestone, 1805,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 2 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section baseline
no_agent (14.839 s) : 14839000, 14839000
. : milestone, 14839000,
appsec (14.78 s) : 14780000, 14780000
. : milestone, 14780000,
iast (18.087 s) : 18087000, 18087000
. : milestone, 18087000,
iast_GLOBAL (17.768 s) : 17768000, 17768000
. : milestone, 17768000,
profiling (14.717 s) : 14717000, 14717000
. : milestone, 14717000,
tracing (14.757 s) : 14757000, 14757000
. : milestone, 14757000,
section candidate
no_agent (15.495 s) : 15495000, 15495000
. : milestone, 15495000,
appsec (14.644 s) : 14644000, 14644000
. : milestone, 14644000,
iast (18.408 s) : 18408000, 18408000
. : milestone, 18408000,
iast_GLOBAL (17.821 s) : 17821000, 17821000
. : milestone, 17821000,
profiling (14.823 s) : 14823000, 14823000
. : milestone, 14823000,
tracing (14.991 s) : 14991000, 14991000
. : milestone, 14991000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~59f02f1399, baseline=1.59.0-SNAPSHOT~c6c245fe4a
dateFormat X
axisFormat %s
section baseline
no_agent (1.469 ms) : 1457, 1480
. : milestone, 1469,
appsec (2.465 ms) : 2412, 2517
. : milestone, 2465,
iast (2.205 ms) : 2140, 2270
. : milestone, 2205,
iast_GLOBAL (2.252 ms) : 2186, 2317
. : milestone, 2252,
profiling (2.48 ms) : 2318, 2642
. : milestone, 2480,
tracing (2.053 ms) : 2002, 2105
. : milestone, 2053,
section candidate
no_agent (1.472 ms) : 1461, 1484
. : milestone, 1472,
appsec (3.712 ms) : 3493, 3930
. : milestone, 3712,
iast (2.201 ms) : 2136, 2265
. : milestone, 2201,
iast_GLOBAL (2.253 ms) : 2188, 2319
. : milestone, 2253,
profiling (2.045 ms) : 1993, 2098
. : milestone, 2045,
tracing (2.046 ms) : 1994, 2098
. : milestone, 2046,
|
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would want to make sure there are no issues with unwrapping in all possible cases. Perhaps keeping the original exception would be helpful for keeping context of where the original exception occurred in the stack trace, because unwrapping will only keep the inner exception's stack trace. Otherwise if this is not a concern, then LGTM
mcculls
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands this will result in both DataFetcherExceptionHandlerParametersInstrumentations being applied to GraphQL versions below 20
The new instrumentation in graphql-java-14.0 will apply because the extra checks that the version is < 20 will pass. But the new instrumentation in graphql-java-20.0 will also apply because it has no checks that the version is >= 20.
This isn't covered by the muzzle checks, because the graphql 20 project is missing a check that the advice there doesn't apply for versions before 20:
fail {
group = "com.graphql-java"
module = 'graphql-java'
versions = '[,20)'
}
PS. muzzle is currently failing for graphql-java-14.0 because the new instrumentation will apply to versions before 14 as well (there's an assertInverse on the graphql-java-14.0 muzzle directive which means check it doesn't match versions outside the directive)
You could fix this up with a bunch of additional checks, but I'm thinking it might make more sense to move DataFetcherExceptionHandlerParametersInstrumentation to the graphql-java-common project and have it just declared once, since we know it will apply to every version of GraphQL. (Maybe at the same time give it a shorter name that indicates what it does, such as GraphQLUnwrapExceptionInstrumentation)
|
Related question to the one from @jordan-wong - do we need to unwind all Also can we assume that the |
|
Thanks for the tips Stuart!
GraphQL already unwraps one layer of
I'm not sure what you mean by current? |
Basically, instead of looping through the entire chain of exceptions collapsing any i.e. do the same as the existing unwrap code in graphql - in other words, could we just unwrap once rather than keep unwrapping |
ValentinZakharov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m concerned the solution doesn’t address the root cause - our instrumentation still returns a derived CompleteStage instead of original one. This could potentially leads to CompletionException been observed outside graphql handler (at HTTP/web-framework layer), so 422->500 issue may happens depends on where HTTP Status mapping happens
Dismissing stale review
| import java.util.concurrent.CompletionException; | ||
|
|
||
| public final class AsyncExceptionUnwrapper { | ||
| private static final int MAX_UNWRAP_DEPTH = 32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can now be removed
| private static final int MAX_UNWRAP_DEPTH = 32; |
|
FYI, merge in latest master to pick up a couple of build-related fixes |
What Does This Do
Currently, if async calls done in the GraphQL result in exceptions, the integration will return the exception wrapped in a
CompletionException. This PR instruments theDataFetcherExceptionHandlerParameters.getExceptionmethod to unwrap the exception of anyCompletionExceptionbefore sending the exception to GraphQL'sDataFetcherExceptionHandler.Note that GraphQL's basic implementation of their
DataFetcherExceptionHandleralready unwraps one layer ofCompletionException.Motivation
Escalation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]